package com.xcdh.ittools.factory;

import lombok.Data;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ValueBean {
    private String filedName ;
    private Method get ;
    private Method set ;


    public ValueBean(String filedName , Method get , Method set){
        this.filedName = filedName;
        this.get = get;
        this.set = set;
    }

    public Object handlerMethod(Method m , Object bean , Object ...args) throws InvocationTargetException, IllegalAccessException {
       return m.invoke(bean , args);
    }

    public void handlerSet(Object bean , Object ...args) throws InvocationTargetException, IllegalAccessException {
        this.handlerMethod(this.set ,bean , args) ;
    }

    public Object handlerGet(Object bean ) throws InvocationTargetException, IllegalAccessException {
       return this.handlerMethod(this.get ,bean , null) ;
    }

    public String getFiledName(){
        return filedName ;
    }

}
